/*
 */

package com.core.basic.secure.dao;

import java.util.*;
import common.base.*;
import common.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.util.page.*;
import cn.org.rapid_framework.page.*;


import com.core.basic.secure.domain.*;
import com.core.basic.secure.dao.*;
import com.core.basic.secure.service.*;
import com.core.basic.secure.query.*;

/**
 */


import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@SuppressWarnings(value = "all")
@Repository
public class MenuDao extends BaseHibernateDao<Menu,java.lang.Integer>{

	public Class getEntityClass() {
		return Menu.class;
	}
	
	public Page<Menu> findPage(MenuQuery query) {
        
        StringBuilder hqlSb = new StringBuilder("SELECT t FROM  Menu t WHERE 1=1 ");
        if(isNotEmpty(query.getId())) {
        	hqlSb.append(" AND  t.id = :id ");
        }
        if(isNotEmpty(query.getName())) {
        	hqlSb.append(" AND  t.name = :name ");
        }
        if(isNotEmpty(query.getLink())) {
        	hqlSb.append(" AND  t.link = :link ");
        }
        if(isNotEmpty(query.getLevel())) {
        	hqlSb.append(" AND  t.level = :level ");
        }
        if(isNotEmpty(query.getParentId())) {
        	hqlSb.append(" AND  t.parentId = :parentId ");
        }
        if(isNotEmpty(query.getNote())) {
        	hqlSb.append(" AND  t.note = :note ");
        }
        if(isNotEmpty(query.getResourceName())) {
        	hqlSb.append(" AND  t.resourceName = :resourceName ");
        }
        if (isNotEmpty(query.getSortColumns())) {
		hqlSb.append("order by "+query.getSortColumns());
	}
		return pageQuery(hqlSb.toString(),query);
	}
	

}
